package com.nightsoul.springboottest2.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.nightsoul.springboottest2.domain.User;

public interface UserMapper {

	@Select("SELECT * FROM user")
	@Results({
		@Result(property="id", column="id"),
		@Result(property="username", column="username"),
		@Result(property="password", column="password"),
		@Result(property="email", column="email"),
		@Result(property="nickName", column="nick_name"),
		@Result(property="regTime", column="reg_time")
	})
	List<User> findAll();

	@Insert("INSERT INTO user(username,password,email,nick_name,reg_time) VALUES(#{username},#{password},#{email},#{nickName},#{regTime})")
	void save(User user);

	@Delete("DELETE FROM user")
	void deleteAll();
}
